﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RevClinic.Core.Domain;
using NHibernate.Criterion;
using NHibernate;

namespace RevClinic.Core.Repositories
{
    public class RoleRepository : IRoleRepository
    {
        private ISession _session;

        public RoleRepository(ISessionFactory factory)
        {
            _session = factory.GetCurrentSession();
        }

        public UserGroup GroupFor(UserType type)
        {
            return _session.CreateCriteria<UserGroup>()
                .Add(Expression.Eq("Owner", type))
                .UniqueResult<UserGroup>();
        }
    }
}
